package nio.example.study.client.codec;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.MessageToMessageEncoder;
import nio.example.study.common.Operation;
import nio.example.study.common.RequestMessage;
import nio.example.study.common.order.OrderOperation;
import nio.example.study.util.IdUtil;

import java.util.List;

public class OperationToRequestMessageEncoder extends MessageToMessageEncoder<Operation> {
	@Override
	protected void encode(ChannelHandlerContext channelHandlerContext, Operation operation, List<Object> out) throws Exception {
		RequestMessage requestMessage = new RequestMessage(IdUtil.nextId(), operation);

		out.add(requestMessage);

	}
}
